var a = getApp();

Page({
    data: {
        role: 2,
        roleName: "",
        province: "重庆市",
        city: "市区",
        pageNo: 1,
        total: -1,
        listDatas: []
    },
    loadData: function(t) {
        var o = this;
        if (t) o.data.pageNo = 1; else if (o.data.total == o.data.listDatas.length) return;
        a.network.post({
            url: a.url.listPlannerHomeHotMore,
            params: {
                pageNo: o.data.pageNo,
                pageSize: 20,
                province: o.data.province,
                city: o.data.city,
                role: o.data.role
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(e) {
                if (1 == e.data.result) {
                    var i = [];
                    t || (i = o.data.listDatas), i = i.concat(e.data.data.users);
                    var s = o.data.pageNo + 1;
                    o.setData({
                        total: e.data.data.total,
                        listDatas: i,
                        pageNo: s
                    });
                } else a.util.showToast(e.data.message);
            },
            fail: function() {
                a.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    tapAvatar: function(t) {
        var o = t.currentTarget.dataset.accesstoken;
        a.util.navToUserHome(o);
    },
    onLoad: function(a) {
        var t = a.rolename;
        wx.setNavigationBarTitle({
            title: "热门" + t
        }), this.setData({
            role: a.role,
            roleName: t,
            province: a.province,
            city: a.city
        }), this.loadData(!0);
    },
    onPullDownRefresh: function() {
        wx.stopPullDownRefresh(), this.loadData(!0);
    },
    onReachBottom: function() {
        this.loadData(!1);
    }
});